package Operations;
import Book.Book;
import Book.BookList;
import java.util.Scanner;

public class Borrowedbook implements Ioperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("借阅图书");
        System.out.print("请输入你想借的书名>>>");
        Scanner scanner=new Scanner(System.in);
        String name=scanner.nextLine();
        for (int i = 0; i < bookList.getSize() ; i++) {
            Book books=bookList.Getpos(i);
            if(name.equals(books.getBook_name())){
                if(books.isIs_borrowed()==true){
                    System.out.println("该书已经被借出");
                    return;
                }else{
                    books.setIs_borrowed(true);
                    System.out.println("借阅成功");
                    return ;
                }
            }
        }
        System.out.println("找不到此书");
    }
}

